<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <link rel="shortcut icon" href="images/favicon.ico"/>
        <title>Facelet Title</title>
        <style type="text/css">
            .pictogram{
                border: 0 black;
                float: left;
                vertical-align:baseline;
                padding:3px;
                height: 20px
            }
        </style>
    </h:head>
    <h:body style="background-color: #111111">
        
       <center>
          
           <p:growl id="messageGrowl" showDetail="true"/>
           <p:dataTable  var="user"
                         value="#{managementBean.userModel}"
                         id="userTable"
                         style="width: 680px"
                         liveScroll="true"
                         paginator="true" rows="10"
                         paginatorTemplate="{PreviousPageLink} {PageLinks} {NextPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="5,10,15"
                         selection="#{managementBean.selectedUser}"
                         selectionMode="single">

               <p:ajax event="rowSelect"/>

                <f:facet name="header">
                    #{resourcesController.extractResource('SYSTEM_USERS')}
                </f:facet>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{resourcesController.extractResource('AVATAR')}" />
                    </f:facet>

                    <p:graphicImage url="#{managementBean.retrieveAvatarPath(user.username)}"
                                    width="45"
                                    style="border-color: black"/>
                </p:column>
               
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{resourcesController.extractResource('LOGIN')}" />
                    </f:facet>

                    <h:outputText value="#{user.username}" />
                </p:column>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{resourcesController.extractResource('EMAIL')}" />
                    </f:facet> 
                    
                       <div>
                          <p:commandLink onclick="mailDlg.show();">  
                            <h:outputText value="#{user.email}"
                                          style="font-size: 10pt"/>
                            <p:graphicImage url="/images/mail.png"
                                            styleClass="pictogram"/>
                          </p:commandLink>
                       </div>
                 
        
                </p:column>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="ID" />
                    </f:facet>
                    <h:outputText value="#{user.id}" />
                </p:column>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="GID" />
                    </f:facet>
                    <h:outputText value="#{user.gid}" />
                </p:column>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="" />
                    </f:facet>
                    <div >

                        <p:commandLink id="assignmoderator"
                                       ajax="false"
                                       async="true"
                                       update="userTable"
                                       action="#{managementBean.assignModerator(user)}">
                            <p:graphicImage url="/images/moderator.png"
                                            styleClass="pictogram"
                                            alt="#{resourcesController.extractResource('ASSIGN_MODER')}"/>
                        </p:commandLink>
                        
                        <p:commandLink id="deleteuser"
                                       ajax="false"
                                       async="true"
                                       update="userTable"
                                       action="#{managementBean.deleteUser(user)}">
                            <p:graphicImage url="/images/delete.png"
                                            styleClass="pictogram"
                                            alt="#{resourcesController.extractResource('REMOVE')}"/>
                        </p:commandLink>
                      
                    </div>
                </p:column>
            </p:dataTable>   
       </center>

        <p:dialog widgetVar="mailDlg">
          <p:panel>
            <h:panelGrid>
                #{resourcesController.extractResource('ENTER_MAIL_TITLE')}
                <p:inputText value="#{managementBean.notificationTitle}"
                             size="29"/>
                #{resourcesController.extractResource('ENTER_MAIL_BODY')}
                <p:inputTextarea value="#{managementBean.notificationText}"
                             cols="30" rows="8"/>
     
                <p:commandButton value="#{resourcesController.extractResource('SEND')}"
                                 async="true"
                                 ajax="false"
                                 actionListener="#{managementBean.sendNotification}"
                                 oncomplete="mailDlg.hide();"/>
            </h:panelGrid>
          </p:panel>
        </p:dialog>
                     
    </h:body>
</html>

